# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/6/1 20:42
from PyQt5.Qt import *


class Window(QMainWindow):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('QToolBar工具栏学习')
		self.resize(500, 500)
		self.move(400,250)
		self.toolbar = QToolBar(self)
		self.text_edit = QTextEdit(self)
		self.setup_ui()
		QDockWidget
		QDockWidget.DockWidgetFeatures

	def set_tool_bar(self):
		self.toolbar.setFloatable(False)
		self.toolbar.addAction('关闭窗口', lambda:self.close())

		self.toolbar.addAction(QIcon("./Icons/text-icons/undo_96px.ico"),'撤销',self.text_edit.undo)
		self.toolbar.addAction(QIcon("./Icons/text-icons/redo_96px.ico"),'重做',self.text_edit.redo)

	def setup_ui(self):
		self.setCentralWidget(self.text_edit)

		# 工具栏
		self.set_tool_bar()
		self.addToolBar(self.toolbar)
		# self.addToolBar(Qt.LeftToolBarArea,self.toolbar)
		# self.addToolBar(Qt.RightToolBarArea,self.toolbar)
		# self.addToolBar(Qt.BottomToolBarArea,self.toolbar)
		# self.addToolBar(Qt.BottomToolBarArea,self.toolbar)






if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	window.show()
	sys.exit(app.exec_())